import {CRS} from "./CRS";
import {LatLngBounds} from "../geom/LatLngBounds";
import {LatLng} from "../geom/LatLng";
import {Vector2} from "three";

/**
 * 平面投影
 */
export class CRS4326 extends CRS {
    bbox: LatLngBounds;

    private readonly ratio = 111000.0;

    projection(latLng: LatLng): Vector2 {
        return new Vector2(latLng.longitude * this.ratio,
            latLng.latitude * this.ratio);
    }

    unProjection(vec: Vector2): LatLng {
        return new LatLng(vec.y / this.ratio, vec.x / this.ratio);
    }

    constructor() {
        super();
        this.bbox = new LatLngBounds(new LatLng(-90.0, -180.0),
            new LatLng(90, 180))
    }
}
